import { RegisterComponent } from "@feng3d/ecs";
import { ColorRepresentation, PolarGridHelper } from "../../thirdparty/three/imports";
import { Component3D } from "../core/Component3D";

declare module "@feng3d/ecs"
{
    interface ComponentMap { PolarGridHelper3D: PolarGridHelper3D; }
}

/**
 * 包装`three`中`PolarGridHelper`。
 */
@RegisterComponent({ name: 'PolarGridHelper3D' })
export class PolarGridHelper3D extends Component3D
{
    _helper: PolarGridHelper;

    radius?: number;
    radials?: number;
    circles?: number;
    divisions?: number;
    color1?: ColorRepresentation;
    color2?: ColorRepresentation;

    init()
    {
        super.init();
        this._helper = new PolarGridHelper(this.radius, this.radials, this.circles, this.divisions, this.color1, this.color2);

        this._entity._group.add(this._helper);
    }

    destroy(): void
    {
        this._entity._group.remove(this._helper);

        this._helper.dispose();
        this._helper = null;

        super.destroy();
    }
}
